interface entityInterface
{
  void addForce(vec2d f);
  void update(float t); 
  void doCollision(Vector v);
  void draw(float x, float y);
}

public abstract class entityAbstractObject implements entityInterface
{
  public vec2d position, velocity, modifier; 
  public boolean active;
  public float rad;
  public float mass;
  public float oneOverMass;

  entityAbstractObject()
  {

    this.position = new vec2d(0,0);
    this.velocity = new vec2d(0,0);
    this.modifier = new vec2d(0,0);

    this.mass = 100;
    this.oneOverMass = 1 / this.mass;

    this.__activate();
  }

  entityAbstractObject(float pX, float pY, float vX, float vY, float mass)
  {
    this.position = new vec2d(pX,pY);
    this.velocity = new vec2d(vX,vY);
    this.modifier = new vec2d(0,0);

    this.mass = mass;
    this.oneOverMass = 1 / this.mass;

    this.__activate();
  }


  void addForce(vec2d f)
  {
    this.modifier.add(f); 
  }

  void update(float t)
  {
    
    float aX = this.modifier.x * this.oneOverMass;
    float aY = this.modifier.y * this.oneOverMass;


    this.velocity.add(aX * t, aY * t);
    this.position.add(this.velocity.x * t, this. velocity.y * t);

    this.modifier = new vec2d(0,0);
  }

  public abstract void doCollision(Vector v);

  void draw(float x, float y)
  {
    fill(255,100);
    stroke(255);
    ellipse(this.position.x + x, this.position.y + y, this.rad, this.rad);
  }

  private void __setPosition(float x, float y)
  {
    this.position.x = x;
    this.position.y = y;
  }

  private void __setVelocity(float x, float y)
  {
    this.velocity.x = x;
    this.velocity.y = y;
  }

  private void __activate()
  {
    this.active = true;
    this.rad = (int)random(mass / 6, mass / 2); 

  }
}
